<template>
  <div>
    <div class="shoppingfooter" v-if="show">
      <van-submit-bar :price="price" button-text="去结算" @submit="onSubmit">
        <van-checkbox v-model="allchecked" >全选</van-checkbox>
      </van-submit-bar>
    </div>
    <div v-if="show1" >
   <FooterBarVue ></FooterBarVue>
    </div>
 
  </div>
</template>

<script>
import FooterBarVue from "@/components/FooterBar.vue";

export default {
  name: "submit",
  data() {
    return {
      allchecked: true,
      show: "",
      show1: true,
      price: 9999900,
    };
  },
  components: {
    FooterBarVue,
  },
  created() {
    this.token = sessionStorage.getItem("token");
    this.userid = sessionStorage.getItem("userid");
    this.proid = this.$route.params.goodsid;

    this.$service({
      method: "post",
      url: "api/cart/list",
      headers: { token: this.token },
      data: `userid=${this.userid}`,
    }).then((res) => {
      console.log("res.data", res.data);

      if (res.data.code == 200) {
        this.show1 = false;
        this.show = true;
      }
      if (res.data.code == 10020) {
        this.show1 = true;
        this.show = false;
      }
    });
  },
  methods: {
    onSubmit() {
      this.$service({
        method: "post",
        url: "api/order/addOrder",
        headers: { token: this.token },
        data: `userid=${this.userid}`,
      }).then((res) => {
        
        if (res.data.code == 200) {
          sessionStorage.setItem("time", res.data.time);
          this.$router.push("/Pay");
        }
      });
     
    },
  },
};
</script>

<style scoped>

</style>